package org.jeecg.modules.extbpm.process.mapper;

import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.extbpm.process.entity.ExtActProcess;
import org.jeecg.modules.extbpm.process.pojo.RoleInfo;
import org.jeecg.modules.extbpm.process.pojo.UserInfo;
import org.jeecgframework.designer.vo.ProcessTypeVo;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @Description: 流程表
 * @author： jeecg-boot
 * @date：   2019-03-15
 * @version： V1.0
 */
public interface ExtActProcessMapper extends BaseMapper<ExtActProcess> {
	
	public List<UserInfo> getBpmUsers();
	
	public List<RoleInfo> getBpmRoles();
	
	public void cleanBpmActIdMembership();
	
	public void cleanBpmActIdUser();
	
	public void cleanBpmActIdGroup();
	
	public List<UserInfo> getSysUsers();
	
	public List<RoleInfo> getSysRolesByUserId(@Param("userId") String userId);
	
	/**
	 * 查询流程类型
	 */
	@Select("select item_value id,item_text typename from sys_dict_item where dict_id = (select id from sys_dict where dict_code=#{code}) order by sort_order asc")
	public List<ProcessTypeVo> getDictItems(@Param("code") String code);
	
	/**
	 * 	根据表名和id查询数据信息
	 * @param name
	 * @param proid
	 * @return
	 */
	@Select("select * from ${tableName} where ID = #{id}")
	@ResultType(Map.class)
	public Map<String,Object> getDataById(@Param("tableName")String tableName,@Param("id")String id);
	
	/**
	 * 	根据表名和id查询数据信息
	 * @param name
	 * @param proid
	 * @return
	 */
	@Update("update ${tableName} set ${col} = #{value}  where ID = #{id}")
	public int updateBpmStatusById(@Param("tableName")String tableName,@Param("id")String id,@Param("col")String col,@Param("value")String value);

	/**
	 * 通过流程名字查询流程定义KEY
	 * @param processName
	 * @return
	 */
	@Select("select process_key from ext_act_process where process_name like concat(concat('%',#{processName}),'%')")
	public List<String> getProcessKeysByProcessName(@Param("processName")String processName);

	List<UserInfo> getPageBpmUsers(IPage<UserInfo> page, @Param("account") String account, @Param("name") String name);
}
